<%--
  Created by IntelliJ IDEA.
  User: 小郭子
  Date: 2022/8/27
  Time: 9:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<html>
<head>
    <title>Title</title>
    <link href="${pageContext.request.contextPath}/statics/layui/css/layui.css" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/statics/jquery-1.6.2.min.js"></script>
</head>
<body>
<div align="center">
<h1>水果详情</h1><br>
<form method="post" action="add" class="layui-form" enctype="multipart/form-data">
    <div style="width: 30%;height: 20%;margin: auto">
<table border="1" class="layui-table">
    <tr>
        <td>类别:</td>
        <td><input type="text" name="type" value="${fruit.type}" onblur="checkType(this)" class="layui-input"><span class="error">${typeError}</span></td>
    </tr>
    <tr>
        <td>品种:</td>
        <td><input type="text" name="breed" value="${fruit.breed}" class="layui-input"><span class="Error">${breedError}</span></td>
    </tr>
    <tr>
        <td>产地:</td>
        <td><input type="text" name="area" value="${fruit.area}" class="layui-input"><span class="Error">${areaError}</span></td>
    </tr>
    <tr>
        <td>简介:</td>
        <td><textarea name="brief" value="${fruit.brief}" class="layui-textarea"></textarea><span class="Error">${priceError}</span></td>
    </tr>
    <tr>
        <td>采摘日期:</td>

        <td><input type="text" name="dataTime" value="<fmt:formatDate value="${fruit.dataTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" class="layui-input"><span class="Error">${dataTimeError}</span></td>
    </tr>
    <tr>
        <td>水果图片:</td>
        <td>
          <input type="file" name="filePic">
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <a href="list" class="layui-btn layui-btn-radius layui-btn-primary">返回</a>
            <input type="submit" class="layui-btn layui-btn-radius layui-btn-danger">
        </td>
    </tr>
</table>
    </div>
</form>
    <script>
        function checkType(el) {
            $.get('checkType',{type:el.value},function (data) {
                if (data=='true'){
                    $(el).next('span').html('该类型已存在')
                }else {
                    $(el).next('span').html('')
                }
            });
        }
    </script>
</div>
</body>
</html>